<?php
/**
 * Created by PhpStorm.
 * User: ly
 * Date: 2018\1\8 0008
 * Time: 10:31
 */
use yii\widgets\LinkPager;
$this->title = '审批管理 - 立项审批';
$this->registerCssFile('@web/css/index.css', ['depends' => ['backend\assets\AppAsset'], 'position' => $this::POS_HEAD]);
$this->registerCssFile('@web/css/mask.css', ['depends' => ['backend\assets\AppAsset'], 'position' => $this::POS_HEAD]);
//$this->registerCssFile('@web/css/AssetPackageDetails.css', ['depends' => ['backend\assets\AppAsset'], 'position' => $this::POS_HEAD]);
//$this->registerCssFile('@web/css/paging.css', ['depends' => ['backend\assets\AppAsset'], 'position' => $this::POS_HEAD]);
//$this->registerCssFile('@web/css/notEdit.css', ['depends' => ['backend\assets\AppAsset'], 'position' => $this::POS_HEAD]);
$this->registerCssFile('@web/css/select2.min.css', ['depends' => ['backend\assets\AppAsset'], 'position' => $this::POS_HEAD]);
$this->registerCssFile('@web/css/defaultTheme.css', ['depends' => ['backend\assets\AppAsset'], 'position' => $this::POS_HEAD]);
$this->registerCssFile('@web/css/myProject.css', ['depends' => ['backend\assets\AppAsset'], 'position' => $this::POS_HEAD]);
$this->registerCss('  
    .un-can-click{cursor: default!important;color: #888888!important;}
');
$shenPiGroup = $type; //根据不同的Group加载不同的页面
$resultAccess = Yii::$app->request->get('result',1); //根据不同的Group加载不同的页面
?>
<style type="text/css">
	
/*//高亮显示和鼠标悬停状态开始*/

table tr:hover{
 background: #e8f4fe;
}
.border td {
	border-top:1px solid #2194f1!important;
	border-bottom:1px solid #2194f1!important;
}

.border td:last-child {
	border-right:1px solid #2194f1!important;
}

.border td:first-child {
	border-left:1px solid #2194f1!important;
}
.border tr:first-child td {
	color: #2194f1!important;
}

a:link{
	text-decoration: none;
}

/*//高亮显示结束和鼠标悬停状态*/
.searchalls {
	border: none!important;
}
#keyWords {
	margin-left: 0px;
	border: 1px solid #E2E2E2;
}
img {
	border-radius: 0px 2px 2px 0px;
}

.wrap > .container-fluid > .container {
    width: 100%!important;
}
.navbar{
    border: none;
}
</style>
<!--一键置 顶-->
<a href="#" class="clicktop" title="返回顶部">
    <!--<img src="image/common/clickTop.png" alt=""  />-->
</a>
<!--一键置 顶结束-->
<!--资产包详情搜索部分开始-->
<div class="myBagSeachBox">
    <div class="container">
        <div class="top">
            <a href="/">办公大厅</a>
            <a href="jascript:;"> > 审批管理</a>
            <a class="pagedetails"> > <?= $shenPiGroup==5?"访问审批":"立项审批";?></a>
        </div>
        <ul id="myTab" class="nav nav-tabs">
            <?php
                if (!empty($is_show)){
                    ?>
                    <li class="<?= $shenPiGroup==1?'active':''?>" id="lxspA">
                        <a href="#lxsp" data-val="1" data-toggle="tab">
                            立项审批<!-- （<span>3</span>） -->
                        </a>
                    </li>
            <?php
                }
            ?>

            <li  id="fwspA" class="<?= $shenPiGroup==5?'active':''?>">
                <a href="#fwsp" data-val="2" data-toggle="tab">
                    访问审批 <!--(<?php /*echo $ShenHeWTGNum+$ShenHeTGNum+$wShenHeNum;*/?>)（<span>3</span>）-->
                </a>
            </li>
            <li id="myAudit">
                <a href="#wfqdsp" data-val="3" data-toggle="tab">
                    我发起的审批<!-- （<span>3</span>） -->
                </a>
            </li>
        </ul>

        <div id="myTabContent" class="tab-content">
            <!-- 1 -->
            <div class="tab-pane fade  <?= $shenPiGroup==1?'in active':''?> " id="lxsp">
                <form method="get" id="settingUp">
                <div class="searchalls clearfix">
                    <input type="text" name="keyWords"  id="keyWords" value="<?php echo Yii::$app->request->get('keyWords','')?>" class="pull-left" placeholder="输入关键字/申请人快速查询" list='searchLi'>
                    <input type="hidden" name="result" id="result" value="<?php echo Yii::$app->request->get('result','')?>">
                    <a href="javascript:settingUpSubmit();" id="subForm"><img src="/image/officeHall/searchs.png" class=""></a>
                    <datalist id='searchLi'>
                        <option>11111111</option>
                        <option>2222</option>
                        <option>3333</option>
                    </datalist>
                </div>
                <div class="state clearfix" id="resultRadio">
                    <div class="top clearfix">
                        <span class="pull-left">审批状态</span>
                        <span class="pull-left canclick <?php echo  Yii::$app->request->get('result','')==''?'stateActive':''?>" result="">不限</span>
                        <span class="pull-left canclick <?php echo  Yii::$app->request->get('result','')==1?'stateActive':''?>" result="1">未审批</span>
                        <span class="pull-left canclick <?php echo  Yii::$app->request->get('result','')>1?'stateActive':''?>" result="4">已审批</span>
                    </div>
                    <div class="bottom clearfix">
                        <span class="pull-left">审批结果</span>
                        <?php
                        if(Yii::$app->request->get('result','')==1){
                            echo '<span class="pull-left canclick un-can-click" result="">不限</span>
                        <span class="pull-left canclick un-can-click" result="2">通过</span>
                        <span class="pull-left canclick un-can-click" result="3">未通过</span>';
                        }else{?>
                        <span class="pull-left canclick <?php echo  Yii::$app->request->get('result','')!=2&&Yii::$app->request->get('result','')!=3?'stateActive':''?>" result="4">不限</span>
                        <span class="pull-left canclick <?php echo  Yii::$app->request->get('result','')==2?'stateActive':''?>" result="2">通过</span>
                        <span class="pull-left canclick <?php echo  Yii::$app->request->get('result','')==3?'stateActive':''?>" result="3">未通过</span>
                        <?php }?>
                    </div>
                </div>
                </form>
            </div>
            <!-- 2访问审批 -->
            <div class="tab-pane fade <?= $shenPiGroup==5?'in active':''?>" id="fwsp">
                <div class="searchalls clearfix">
                    <input type="text" value="<?= \Yii::$app->request->get('accessKey','');?>" name="" id="accessKey" class="pull-left" placeholder="输入关键字/申请人快速查询" list='searchLi'>
                    <img src="/image/officeHall/searchs.png" id="searchImg" class="">
                    <datalist id='searchLi'>
                        <option>11111</option>
                        <option>2222</option>
                        <option>3333</option>
                    </datalist>
                </div>
                <div class="state clearfix">
                    <div class="top clearfix">
                        <span class="pull-left">审批状态</span>
                        <span class="pull-left resultFW <?= $resultAccess==0?'stateActive':''?>" data-val="0">不限</span>
                        <span class="<?= $resultAccess==1?'stateActive':''?> pull-left resultFW" data-val="1">未审批<?php echo !empty($wShenHeNum)?'('.$wShenHeNum.')':'';?></span>
                        <?php
                            if (!empty($ShenHeTGNum) || !empty($ShenHeWTGNum)){
                                $ShenHeNum = $ShenHeTGNum + $ShenHeWTGNum;
                            }else{
                                $ShenHeNum = 0;
                            }
                        ?>
                        <span class="pull-left resultFW <?= $resultAccess==4?'stateActive':''?>" data-val="4">已审批<?= '('.$ShenHeNum.')';?></span>
                    </div>
                    <div class="bottom clearfix">
                        <span class="pull-left">审批结果</span>
                        <span class="pull-left resultFWD <?= $resultAccess==5?'stateActive':''?>" data-val="5">不限</span>
                        <span class="<?= $resultAccess==2?'stateActive':''?> pull-left resultFWD" data-val="2">通过<?php echo !empty($ShenHeTGNum)?'('.$ShenHeTGNum.')':'';?></span>
                        <span class="pull-left resultFWD <?= $resultAccess==3?'stateActive':''?>" data-val="3">未通过<?php echo !empty($ShenHeWTGNum)?'('.$ShenHeWTGNum.')':'';?></span>
                    </div>
                </div>
            </div>
            <!-- 3 -->
            <div class="tab-pane fade " id="wfqdsp">
                <div class="searchalls clearfix">
                    <input type="text" name="" class="pull-left" placeholder="输入关键字/申请人快速查询" list='searchLi'>
                    <img src="/image/officeHall/searchs.png" class="">
                    <datalist id='searchLi'>
                        <option>11111</option>
                        <option>2222</option>
                        <option>3333</option>
                    </datalist>
                </div>
                <div class="state clearfix">
                    <div class="top clearfix">
                        <span class="pull-left">审批状态</span>
                        <span class="pull-left">不限(3)</span>
                        <span class="stateActive pull-left">未审批</span>
                        <span class="pull-left">已审批</span>
                    </div>
                    <div class="bottom clearfix">
                        <span class="pull-left">审批结果</span>
                        <span class="pull-left">不限</span>
                        <span class="stateActive pull-left">通过</span>
                        <span class="pull-left">未通过</span>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
<!--审批列表列表结开始-->
<div class="myApproval myAccess">
    <?php
        switch ($shenPiGroup){
            case 1:
                echo  $this->render('myApproval', ['data' => $data, 'pages'=>$pages]);
                break;
            case 5:
                echo  $this->render('myAccess', ['data' => $data, 'pages'=>$pages]);
                break;
            default:
                echo  $this->render('myApproval', ['data' => $data, 'pages'=>$pages]);
                break;
        }
    ?>
</div>



<!-- Modal -->
<div class="modal fade" id="AssetPackageEditing-approval" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <?php
    switch ($shenPiGroup){
        case 1:
            echo  $this->render('myModalLabel', []);
            break;
        case 5:
            echo  $this->render('myModalLabelAccess', []);
            break;
        default:
            echo  $this->render('myModalLabel', []);
            break;
    }
    ?>
</div>
<!-- 模态窗口  结束!!!!!!!!!!!!!!!!!!!!!!!!!!! -->


	<!-- textarea 高度设置对比div -->

<div style="max-height: 1px; overflow: hidden;">
	
	<div id="d1" style="visibility:hidden;min-height: 80px;"></div>

</div>

    <!--<script type="text/javascript" src="js/jquery.min.js" ></script>-->
    <!-- 固定表格头插件 -->
    <script type="text/javascript" src="/js/jquery.fixedheadertable.js"></script>
    <!--<script type="text/javascript" src="js/common.js" ></script>-->
    <!--<script type="text/javascript" src="js/bootstrap.min.js"></script>-->
    <script type="text/javascript" src="/js/index.js"></script>
    <script type="text/javascript" src="/js/paging.js"></script>
    <script type="text/javascript" src="/js/jquery.validate.min.js"></script>
    <script type="text/javascript" src="/js/messages_zh.js"></script>
    <script type="text/javascript" src="/js/select2.min.js"></script>
    <!--<script type="text/javascript" src="js/AssetPackageDetails.js"></script>-->
    <!--//本页js代码-->
    <script type="text/javascript" src="/js/myProject.js"></script>
    <!--//审核页js代码-->
    <script type="text/javascript" src="/js/approval.js"></script>

<script>
    $(function () {
    	//单击tabel 进行高亮显示
		$(document).on('click','tr td',function(){
			$(this).parent().addClass('border').siblings().removeClass('border')
		})
    	// textarea 高度展示问题
	    $(".textarea-edit").keyup(function(){
	         
	      var val = $(this).val();
	      $("#d1").html("<pre>" +val+" "+"</pre>");
	      var h = $("#d1").height() ;
	      $(this).height(h);
	    });
        //---------------立项审批------(fly)------------------
        $("#lxspA").click(function () {
            lxspVal = $("#lxspA").data('val');    //暂不用。以后用来识别是哪组查询
            lxspType = '<?= Yii::$app->params["LIXIANG"];?>';
            var url = '/audit-management/';
            var data = {
                'dianji':1 //通过点击本页面按钮，不跳转
            };
            $.get(url,data,function (res) {
                $(".myAccess").children().remove();
                $(".myAccess").html(res);
                var state = { 'page_id': 1, 'user_id': 5 };
                var title = 'Hello World';
                var url = '/audit-management?shenPiGroup='+1;
                window.history.pushState(state, title, url);
            })
        })
        //---------------立项审批------(fly)------------------

        //我的审批
        $('#myAudit').click(function () {
            window.location.href="/audit-management/my-application";
        })

        //-----------------访问审批-------(fly)--------------
        var resultFW = '<?= !empty(Yii::$app->request->get('resultFW',0));?>';
        var resultFWD = '<?= !empty(Yii::$app->request->get('resultFW',0));?>';
        var accessKey = '<?= !empty(Yii::$app->request->get('accessKey',0));?>';
        $("#fwspA").click(function () {
            fwspVal = $("#fwspA").data('val');    //暂不用。以后用来识别是哪组查询
            shenPiGroup = '<?= Yii::$app->params["FANGWEN"];?>';
            ajaxGetData(shenPiGroup,resultFW,resultFWD,accessKey)
        })
        $("#searchImg").click(function () {
            accessKey = $("#accessKey").val();
            shenPiGroup =  '<?= Yii::$app->params["FANGWEN"];?>';
            ajaxGetDataTZ(shenPiGroup,resultFW,resultFWD,accessKey)
        })
        $(".resultFW").click(function () {
            accessKey = $("#accessKey").val();
            resultFW = $(this).data('val');
            shenPiGroup =  '<?= Yii::$app->params["FANGWEN"];?>';
            ajaxGetData(shenPiGroup,resultFW,resultFWD,accessKey)
        })
        $(".resultFWD").click(function () {
            accessKey = $("#accessKey").val();
            resultFWD = $(this).data('val');
            shenPiGroup =  '<?= Yii::$app->params["FANGWEN"];?>';
            ajaxGetData(shenPiGroup,resultFW,resultFWD,accessKey)
        })
        /*触发回车提交*/
        $(this).keydown(function (e){
            //当点击第二个按钮 访问审批 的时候 屏蔽回车按钮
            if ( $("#fwspA").hasClass('active')){
                accessKey = $("#accessKey").val();
                shenPiGroup =  '<?= Yii::$app->params["FANGWEN"];?>';
                if(e.which == "13"){
                    ajaxGetDataTZ(shenPiGroup,resultFW,resultFWD,accessKey)
                }
            }

        })
        function ajaxGetDataTZ(shenPiGroup,result,resultD,accessKey) {
            var url = '/audit-management/access/';
            var data = {
                'shenPiGroup':shenPiGroup,
                'result'  :  result,
                'resultD'  :  resultD,
                'accessKey':accessKey,
            };
            $.get(url,data,function (res) {
                $(".myAccess").children().remove();
                $(".myAccess").html(res);
                var state = { 'page_id': 1, 'user_id': 5 };
                var title = 'Hello World';
                var url = '/audit-management/access?shenPiGroup='+shenPiGroup+'&result='+result+'&accessKey='+accessKey;
                window.history.pushState(state, title, url);
                location.reload();
            })
        }
        function ajaxGetData(shenPiGroup,result,resultD,accessKey) {
            var url = '/audit-management/access/';
            var data = {
                'shenPiGroup':shenPiGroup,
                'result'  :  result,
                'resultD'  :  resultD,
                'accessKey':accessKey,
            };
            $.get(url,data,function (res) {
                $(".myAccess").children().remove();
                $(".myAccess").html(res);
                var state = { 'page_id': 1, 'user_id': 5 };
                var title = 'Hello World';
                var url = '/audit-management/access?shenPiGroup='+shenPiGroup+'&result='+result+'&accessKey='+accessKey;
                window.history.pushState(state, title, url);
//                location.reload();
            })
        }
        //-----------------访问审批---------(fly)------------
        
        //搜索高亮显示
        //    	搜索框高亮显示
      $('input[type="text"]').focus(function(){
      	$(this).css({
      		'border':'1px solid #2194f1'
      	})
      	$('input[type="text"]').blur(function(){
      		$(this).css({
      			"border":"1px solid #e2e2e2"
      		})
      	})
      })
    })
    
    $(document).on('scroll',function(){
    	//		 	一键置顶开始
	 	if($(window).height() < getScrollTop()) {
			$('.clicktop').show();
		} else {
			$('.clicktop').hide();
		}
		//		 	一键置顶结
    })
    
	/**
	 * 获取页面滚动距离

	 * @return 支持IE6
	 */
	function getScrollTop() {
		var scrollPos;
		if(window.pageYOffset) {
			scrollPos = window.pageYOffset;
		} else if(document.compatMode && document.compatMode != 'BackCompat') {
			scrollPos = document.documentElement.scrollTop;
		} else if(document.body) {
			scrollPos = document.body.scrollTop;
		}
		return scrollPos;
	}
</script>
